using System.ComponentModel.Composition;
using EveIntel.API;
using EveIntel.API.Base;
using EveIntel.API.Enums;
using EveIntel.API.Interfaces;

namespace JovelabsProvider
{
    using System.Globalization;
    using System;

    [Provider]
    [Export(typeof(IIntelProvider))]
    public sealed class JoveLabsProvider : IntelProviderBase
    {
        private const string SOLARSYSTEM_URL = "http://www.jovelabs.com/system/{0}";
        private const string SOLARSYSTEM_TRENDS_URL = "http://www.jovelabs.com/system/{0}/trends";


        public JoveLabsProvider()
            : base(new Guid("3646A46C-23E6-4C93-962E-79B09EC4B599"))
        {
        }
        /// <summary>
        /// Obtains a data provider description
        /// </summary>
        public override string Description
        {
            get { return "www.jovelabs.com"; }
        }
        /// <summary>
        /// Obtains the URI to navigate to
        /// </summary>
        /// <param name="type">The IntelTypeEnum value</param>
        /// <param name="args">Additional arguments needed to build the uri</param>
        /// <returns></returns>
        public override Uri GetUri(IntelTypeEnum type, string[] args)
        {
            if (!CanProvideIntel(type)) return null;
            return new Uri(string.Format(
                 CultureInfo.InstalledUICulture,
                 type == IntelTypeEnum.SolarSystem ? SOLARSYSTEM_URL : SOLARSYSTEM_TRENDS_URL,
                 args[0]));
        }
        /// <summary>
        /// Determines if the data provider can handle a type of intel request
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public override bool CanProvideIntel(IntelTypeEnum type)
        {
            return type == IntelTypeEnum.SolarSystem || type == IntelTypeEnum.Trends;
        }
    }
}